
package br.com.goldentrade.negocio.beans;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "corretora")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Corretora.findAll", query = "SELECT c FROM Corretora c"),
    @NamedQuery(name = "Corretora.findByCdCorretora", query = "SELECT c FROM Corretora c WHERE c.cdCorretora = :cdCorretora"),
    @NamedQuery(name = "Corretora.findByNmCorretora", query = "SELECT c FROM Corretora c WHERE c.nmCorretora = :nmCorretora"),
    @NamedQuery(name = "Corretora.findByTxLiquidacao", query = "SELECT c FROM Corretora c WHERE c.txLiquidacao = :txLiquidacao"),
    @NamedQuery(name = "Corretora.findByIss", query = "SELECT c FROM Corretora c WHERE c.iss = :iss"),
    @NamedQuery(name = "Corretora.findByVlCorretagemFixa", query = "SELECT c FROM Corretora c WHERE c.vlCorretagemFixa = :vlCorretagemFixa"),
    @NamedQuery(name = "Corretora.findByVlCorretagemVariavel", query = "SELECT c FROM Corretora c WHERE c.vlCorretagemVariavel = :vlCorretagemVariavel"),
    @NamedQuery(name = "Corretora.findByVlTaxaAdicVarial", query = "SELECT c FROM Corretora c WHERE c.vlTaxaAdicVarial = :vlTaxaAdicVarial"),
    @NamedQuery(name = "Corretora.findByVlTaxaRegDaytrade", query = "SELECT c FROM Corretora c WHERE c.vlTaxaRegDaytrade = :vlTaxaRegDaytrade"),
    @NamedQuery(name = "Corretora.findByVlTaxaRegNormal", query = "SELECT c FROM Corretora c WHERE c.vlTaxaRegNormal = :vlTaxaRegNormal"),
    @NamedQuery(name = "Corretora.findByDtCadastro", query = "SELECT c FROM Corretora c WHERE c.dtCadastro = :dtCadastro")})
public class Corretora implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "cd_corretora")
    private Integer cdCorretora;
    @Column(name = "nm_corretora")
    private String nmCorretora;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "tx_liquidacao")
    private Float txLiquidacao;
    @Column(name = "iss")
    private Float iss;
    @Column(name = "vl_corretagem_fixa")
    private Float vlCorretagemFixa;
    @Column(name = "vl_corretagem_variavel")
    private Float vlCorretagemVariavel;
    @Column(name = "vl_taxa_adic_varial")
    private Float vlTaxaAdicVarial;
    @Column(name = "vl_taxa_reg_daytrade")
    private Float vlTaxaRegDaytrade;
    @Column(name = "vl_taxa_reg_normal")
    private Float vlTaxaRegNormal;
    @Column(name = "dt_cadastro")
    @Temporal(TemporalType.DATE)
    private Date dtCadastro;
    
    @OneToMany(mappedBy = "cdCorretora")
    private List<EstrategiaOperacao> estrategiaOperacaoList;
   
    @JoinColumn(name = "cd_usuario", referencedColumnName = "cd_usuario")
    @ManyToOne(optional = false)
    private Usuario cdUsuario;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdCorretora")
    private List<Operacao> operacaoList;

    public Corretora() {
    }

    public Corretora(Integer cdCorretora) {
        this.cdCorretora = cdCorretora;
    }

    public Integer getCdCorretora() {
        return cdCorretora;
    }

    public void setCdCorretora(Integer cdCorretora) {
        Integer oldCdCorretora = this.cdCorretora;
        this.cdCorretora = cdCorretora;
        changeSupport.firePropertyChange("cdCorretora", oldCdCorretora, cdCorretora);
    }

    public String getNmCorretora() {
        return nmCorretora;
    }

    public void setNmCorretora(String nmCorretora) {
        String oldNmCorretora = this.nmCorretora;
        this.nmCorretora = nmCorretora;
        changeSupport.firePropertyChange("nmCorretora", oldNmCorretora, nmCorretora);
    }

    public Float getTxLiquidacao() {
        return txLiquidacao;
    }

    public void setTxLiquidacao(Float txLiquidacao) {
        Float oldTxLiquidacao = this.txLiquidacao;
        this.txLiquidacao = txLiquidacao;
        changeSupport.firePropertyChange("txLiquidacao", oldTxLiquidacao, txLiquidacao);
    }

    public Float getIss() {
        return iss;
    }

    public void setIss(Float iss) {
        Float oldIss = this.iss;
        this.iss = iss;
        changeSupport.firePropertyChange("iss", oldIss, iss);
    }

    public Float getVlCorretagemFixa() {
        return vlCorretagemFixa;
    }

    public void setVlCorretagemFixa(Float vlCorretagemFixa) {
        Float oldVlCorretagemFixa = this.vlCorretagemFixa;
        this.vlCorretagemFixa = vlCorretagemFixa;
        changeSupport.firePropertyChange("vlCorretagemFixa", oldVlCorretagemFixa, vlCorretagemFixa);
    }

    public Float getVlCorretagemVariavel() {
        return vlCorretagemVariavel;
    }

    public void setVlCorretagemVariavel(Float vlCorretagemVariavel) {
        Float oldVlCorretagemVariavel = this.vlCorretagemVariavel;
        this.vlCorretagemVariavel = vlCorretagemVariavel;
        changeSupport.firePropertyChange("vlCorretagemVariavel", oldVlCorretagemVariavel, vlCorretagemVariavel);
    }

    public Float getVlTaxaAdicVarial() {
        return vlTaxaAdicVarial;
    }

    public void setVlTaxaAdicVarial(Float vlTaxaAdicVarial) {
        Float oldVlTaxaAdicVarial = this.vlTaxaAdicVarial;
        this.vlTaxaAdicVarial = vlTaxaAdicVarial;
        changeSupport.firePropertyChange("vlTaxaAdicVarial", oldVlTaxaAdicVarial, vlTaxaAdicVarial);
    }

    public Float getVlTaxaRegDaytrade() {
        return vlTaxaRegDaytrade;
    }

    public void setVlTaxaRegDaytrade(Float vlTaxaRegDaytrade) {
        Float oldVlTaxaRegDaytrade = this.vlTaxaRegDaytrade;
        this.vlTaxaRegDaytrade = vlTaxaRegDaytrade;
        changeSupport.firePropertyChange("vlTaxaRegDaytrade", oldVlTaxaRegDaytrade, vlTaxaRegDaytrade);
    }

    public Float getVlTaxaRegNormal() {
        return vlTaxaRegNormal;
    }

    public void setVlTaxaRegNormal(Float vlTaxaRegNormal) {
        Float oldVlTaxaRegNormal = this.vlTaxaRegNormal;
        this.vlTaxaRegNormal = vlTaxaRegNormal;
        changeSupport.firePropertyChange("vlTaxaRegNormal", oldVlTaxaRegNormal, vlTaxaRegNormal);
    }

    public Date getDtCadastro() {
        return dtCadastro;
    }

    public void setDtCadastro(Date dtCadastro) {
        Date oldDtCadastro = this.dtCadastro;
        this.dtCadastro = dtCadastro;
        changeSupport.firePropertyChange("dtCadastro", oldDtCadastro, dtCadastro);
    }

    @XmlTransient
    public List<EstrategiaOperacao> getEstrategiaOperacaoList() {
        return estrategiaOperacaoList;
    }

    public void setEstrategiaOperacaoList(List<EstrategiaOperacao> estrategiaOperacaoList) {
        this.estrategiaOperacaoList = estrategiaOperacaoList;
    }

    public Usuario getUsuario() {
        return cdUsuario;
    }

    public void setUsuario(Usuario cdUsuario) {
        Usuario oldCdUsuario = this.cdUsuario;
        this.cdUsuario = cdUsuario;
        changeSupport.firePropertyChange("cdUsuario", oldCdUsuario, cdUsuario);
    }

    @XmlTransient
    public List<Operacao> getOperacaoList() {
        return operacaoList;
    }

    public void setOperacaoList(List<Operacao> operacaoList) {
        this.operacaoList = operacaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdCorretora != null ? cdCorretora.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Corretora)) {
            return false;
        }
        Corretora other = (Corretora) object;
        if ((this.cdCorretora == null && other.cdCorretora != null) || (this.cdCorretora != null && !this.cdCorretora.equals(other.cdCorretora))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.goldentrade.negocio.Corretora[ cdCorretora=" + cdCorretora + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
